//void, Obj This

Building this;
ObjList ol;
int i;
int nSleepTime, maxLevel;
Unit u;

Sleep(13040+rand(GetConst("RandTimeStart"))+GetConst("AddTimeStart"));

nSleepTime = GetConst("IOutpostExpTick");

this = This.AsBuilding();

maxLevel = 8;

while(1){

	if(EnvReadString(.settlement, "Outpost Level 1") == "researched"){ 
        maxLevel = 10;
        if(EnvReadString(.settlement, "Outpost Level 2") == "researched"){
            maxLevel = 14;
        }
	}
	ol = .settlement.Units;
	ol.ClearDead();
	for (i = 0; i < ol.count; i += 1)
	{
		u = ol[i].AsUnit;
		if (!u.IsValid) continue;
		if (.IsEnemy(u)) continue;
		if (u.inherentlevel >= maxLevel) continue;
		u.SetExperience(u.experience + 1);
	}
	Sleep(nSleepTime);
}
